package com.tbit.main.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tbit.main.dao.log.DispatchApplyMachineMapper;
import com.tbit.main.pojo.DispatchApplyMachine;
import com.tbit.main.service.DispatchApplyMachineService;
import com.tbit.main.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author: chen
 * @Description: 调度申请车辆
 * @Date: 创建于 15:57 2023/2/10
 */
@Service
public class DispatchApplyMachineServiceImpl extends ServiceImpl<DispatchApplyMachineMapper, DispatchApplyMachine> implements
        DispatchApplyMachineService {

    @Autowired
    private DispatchApplyMachineMapper dispatchApplyMachineMapper;

    @Override
    public List<Integer> getStateMachineId(List<Integer> machineId, Integer accountId) {
        Map<String, Object> map = new HashMap<>();
        map.put("machineId", StringUtil.getListString(machineId));
        map.put("accountId", accountId);
        return dispatchApplyMachineMapper.getstateMachineId(map);
    }

    @Override
    @Transactional(value = "logTransactionManager",propagation = Propagation.REQUIRED)
    public boolean saveBatch(Collection<DispatchApplyMachine> entityList) {
        return super.saveBatch(entityList);
    }
}
